package org.j2eeframework.commons.struts2.component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ui.AbstractUITag;

import com.opensymphony.xwork2.util.ValueStack;

public class PaginationTag extends AbstractUITag {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3874059130730031435L;
	
	private String template = Pagination.DEFAULT_TEMPLATE;

	/**
	 * getBean（）返回该Tag中的UIBean。
	 * 
	 * @see org.apache.struts2.views.jsp.ComponentTagSupport#getBean(com.opensymphony.xwork2.util.ValueStack,
	 *      javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public Component getBean(ValueStack stack, HttpServletRequest req,
			HttpServletResponse res) {
		return new Pagination(stack, req, res);
	}

	/**
	 * populateParams()初始化参数，一般用来初始化UIBean(Component)。
	 * 
	 * @see org.apache.struts2.views.jsp.ui.AbstractUITag#populateParams()
	 */
	protected void populateParams() {
		super.populateParams();
		Pagination pagination = (Pagination) component;
		pagination.setTemplate(template);
	}

	public void setTemplate(String template) {
		this.template = template;
	}

}
